﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Asteroids
{
    class Asteroid : SpaceItem
    {
        public Boolean isBullet;
        public Boolean isMagnetized = false;
        public Enemy target;

        public Asteroid(int typ, Vector2 pos, Vector2 vel)
            : base(pos, vel)
        {
            ItemModel type = Game1.asteroidTypes[typ];
            Texture2D texture = type.texture;
            m_sprite = new AnimatedSprite(texture, 0, 0, texture.Width, texture.Height, 1);
            health = type.health;
            m_maxThrust = type.maxSpeed;
            m_mass = type.mass;
            radius = type.radius;
            rotation = m_random.Next(0, (int)(2 * Math.PI));
            isBullet = type.isBullet;

            if (isBullet)
                touched = true;
        }

        public override void Draw(SpriteBatch sb)
        {
            if(exploder)
                m_sprite.Draw(sb, position, centerPosition, rotation % (float)(Math.PI * 2),Color.Red);
            else if(isMagnetized)
                m_sprite.Draw(sb, position, centerPosition, rotation % (float)(Math.PI * 2), Color.Green);
            else
                m_sprite.Draw(sb, position, centerPosition, rotation % (float)(Math.PI * 2));
        }
    }
}


